package logic

import (
	"context"

	"go-zero-service/service/user/api/internal/svc"
	"go-zero-service/service/user/api/internal/types"
	"go-zero-service/service/user/model"

	"github.com/zeromicro/go-zero/core/logx"
)

type InfosaveLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewInfosaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfosaveLogic {
	return &InfosaveLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *InfosaveLogic) Infosave(req *types.InfoSaveReq) (resp *types.InfoSaveReply, err error) {
	// todo: add your logic here and delete this line
	result := l.svcCtx.UserModel.Where("mobile = ?", req.Mobile).Updates(model.User{Username: req.Username})

	return &types.InfoSaveReply{
		Status: true,
	}, result.Error
	return
}
